package com.beta.pay.yeepay.core;

import com.beta.pay.yeepay.utils.ZGTUtils;

import java.math.BigDecimal;

/**
 * Created by vector on 2016/11/30.
 */
public class Yeepay {

    private String apiKey;

    private String apiSecret;

    /**
     * 交易手续费
     */
    private BigDecimal feeRate;

    /**
     * 支付的回调地址，可以在此处统一配置，也可以通过payRequest覆写
     */
    private String payCallbackUrl;

    /**
     * 网页回调地址
     */
    private String webPayCallbackUrl;

    /**
     * 支付组件
     */
    private Pays pays;

    /**
     * 分账组件
     */
    private Divide divide;

    /**
     * 退款组件
     */
    private Refund refund;

    /**
     * 订单组件
     */
    private Orders orders;

    /**
     * 注册组件
     */
    private Register register;

    public Yeepay(String apiKey, String apiSecret) {
        this.apiKey = apiKey;
        this.apiSecret = apiSecret;

        ZGTUtils.setCustomernumber(apiKey);
        ZGTUtils.setHmac(apiSecret);
        init();
    }

    public Yeepay init() {
        pays = new Pays(this);
        divide = new Divide(this);
        refund = new Refund(this);
        orders = new Orders(this);
        return this;
    }

    public String getApiKey() {
        return apiKey;
    }

    public void setApiKey(String apiKey) {
        this.apiKey = apiKey;
    }

    public String getApiSecret() {
        return apiSecret;
    }

    public void setApiSecret(String apiSecret) {
        this.apiSecret = apiSecret;
    }

    public BigDecimal getFeeRate() {
        return feeRate;
    }

    public void setFeeRate(BigDecimal feeRate) {
        this.feeRate = feeRate;
    }

    public String getPayCallbackUrl() {
        return payCallbackUrl;
    }

    public void setPayCallbackUrl(String payCallbackUrl) {
        this.payCallbackUrl = payCallbackUrl;
    }

    public String getWebPayCallbackUrl() {
        return webPayCallbackUrl;
    }

    public void setWebPayCallbackUrl(String webPayCallbackUrl) {
        this.webPayCallbackUrl = webPayCallbackUrl;
    }

    public Pays pays() {
        return pays;
    }

    public Divide divide() {
        return divide;
    }

    public Refund refund() {
        return this.refund;
    }

    public Orders orders() {
        return orders;
    }

    public Register register() {
        return register;
    }
}
